package org.firefly.db.meta;

import java.util.ArrayList;
import java.util.List;

/**
 * 表
 * @author firefly
 *
 */
public class TableMeta {
	//表名
	private String name;
	//表列
	private List<ColumnMeta> columnMetaLs=new ArrayList<ColumnMeta>();
	//约束
	private List<IConstraint> constraintLs=new ArrayList<IConstraint>();
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public List<ColumnMeta> getColumnMetaLs() {
		return columnMetaLs;
	}
	public void setColumnMetaLs(List<ColumnMeta> columnMetaLs) {
		this.columnMetaLs = columnMetaLs;
	}
	public List<IConstraint> getConstraintLs() {
		return constraintLs;
	}
	public void setConstraintLs(List<IConstraint> constraintLs) {
		this.constraintLs = constraintLs;
	}
	
	/**
	 * 获取主键名
	 * @return
	 */
	public String getPKname(){
		String pkName="";
		for (IConstraint c : constraintLs) {
			if(c instanceof PK){
				pkName = PK.class.cast(c).getPkTableColumn();
			}
		}
		return pkName;
	}

}
